<template>
	<jk-dialog
		v-model="showDialog"
		:title="`${processItem ? processItem.processName : '工序'}机台`"
		width="800px"
		:show-content-loading="showLoading"
		:append-to-body="false"
		:modal-append-to-body="false"
		:modal="false"
		:show-close-btn="true"
		:show-confirm-btn="false"
		:show-cancel-btn="false"
		@on-close="onVisibleChange(false)"
		@on-visible-change="onVisibleChange"
	>
		<jk-table border :stripe="false" :show-header="true" :data="processItem.productOrderMachineList" :height="300">
			<vxe-column title="机台" align="left" field="machineCode" :width="90">
				<template slot-scope="scope">
					<div class="flex-start-center">
						<jk-state-bar :state="scope.row.openingState" :state-list="openStateList" :show-text="false" class=""></jk-state-bar>
						<span>{{ scope.row.machineName }}</span>
					</div>
				</template>
			</vxe-column>
			<!--<vxe-column title="产量(M)" align="right" field="accumulateOutput" :width="100"></vxe-column>-->
			<vxe-column title="实时产量(kg)" align="right" field="accumulateShiftQty" :width="100"></vxe-column>
			<vxe-column title="称重产量(kg)" align="right" field="accumulateWeighNetWeight" :width="100"></vxe-column>
			<vxe-column title="能耗(kw·h)" align="right" field="accumulateEnergy" :width="90"></vxe-column>
			<vxe-column title="工时" align="right" field="workHours" :width="70"></vxe-column>
			<vxe-column title="开台时间" align="center" field="startTime" :min-width="90">
				<template slot-scope="scope">
					<div class="flex-center" style="flex-direction: column;">
						<span style="line-height: 13px;">{{ scope.row.startTime ? scope.row.startTime.split(' ')[0] : '' }}</span>
						<span style="line-height: 13px;">{{ scope.row.startTime ? scope.row.startTime.split(' ')[1] : '' }}</span>
					</div>
				</template>
			</vxe-column>
			<vxe-column title="了机时间" align="center" field="endTime" :min-width="90">
				<template slot-scope="scope">
					<div class="flex-center" style="flex-direction: column;">
						<span style="line-height: 13px;">{{ scope.row.endTime ? scope.row.endTime.split(' ')[0] : '' }}</span>
						<span style="line-height: 13px;">{{ scope.row.endTime ? scope.row.endTime.split(' ')[1] : '' }}</span>
					</div>
				</template>
			</vxe-column>
		</jk-table>
	</jk-dialog>
</template>

<script>
    import calHeight from '/src/mixins/cal-table-height';
    import { openStateList } from '../../../../utils/jk/status-option-list';
    export default {
        props: {
            dialogState: {
                type: Boolean,
                default: false
            },
            processItem: {
                type: Object,
                default() {
                    return {};
                }
            }
        },
        mixins: [calHeight],
        data() {
            return {
                openStateList: openStateList,
                showDialog: false,
                showLoading: false,
                ruleForm: {}
            };
        },
        methods: {
            onVisibleChange(e) {
                this.$emit('on-visible-change', e);
                if (!e) {
                    Object.assign(this.$data, this.$options.data());
                }
            }
        },
        watch: {
            dialogState(newVal) {
                this.showDialog = newVal;
            }
        }
    };
</script>
